#!/usr/bin/env python3

from itertools import cycle
from time import sleep
from quick2wire.gpio import pins, Out

pins = [pins.pin(i, Out) for i in range(8)]

try:
    for p in pins:
        p.open()
    
    for count in cycle(range(256)):
        bitset = [int(count & (1<<n) > 0) for n in range(8)]
        for (pin, value) in zip(pins, bitset):
            pin.value = value
        sleep(0.5)
finally:
    for p in pins:
        p.close()
